import request from '@/utils/request'

/**
 * 商品详情
 * @param {String} id - 商品ID
 * @returns Promise
 */
export const findGoods = (id) => {
  return request('/goods', 'get', { id })
}

/**
 * 相关商品
 * @param {String} id - 商品ID
 * @param {String} limit - 数量
 * @returns Promise
 */
export const findRelevantGoods = ({ id, limit = 16 }) => {
  return request('/goods/relevant', 'get', { id, limit })
}

/**
 * 榜单数据
 * @param {String} id - 商品ID
 * @param {Integer} limit - 商品数量
 * @param {Integer} type - 热销类型 1: 24h 2: 7天 3: 总 默认: 1
 * @returns Promise
 */
export const findGoodsHot = ({ id, limit = 3, type = 1 }) => {
  return request('/goods/hot', 'get', { id, limit, type })
}

/**
 * 商品评价
 * @param {String} id - 商品ID
 * @returns Promise
 */
export const findGoodsCommentInfo = (id) => {
  return request(`/goods/${id}/evaluate`, 'get')
  // return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate`, 'get')
}

/**
 * 商品评价列表
 * @param {String} id - 商品ID
 * @param {Object} params - 筛选条件
 * @returns Promise
 */
export const findGoodsCommentList = (id, params) => {
  // return request(`/goods/${id}/evaluate/page`, 'get', params)
  return request(`https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate/page`, 'get', params)
}
